from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep
from selenium.webdriver import Keys
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome()
driver.get('http://192.168.1.37/ranzhi/www/sys/user-login.html')
username = driver.find_element(By.ID,'account')
username.send_keys('admin')
password = driver.find_element(By.ID,'password')
password.send_keys('123456')
login = driver.find_element(By.ID,'submit')
login.click()
# driver.get('http://192.168.1.37/ranzhi/www/sys/user-create.html')
sleep(5)
addBlock = driver.find_element(By.XPATH,'//*[@id="mainNavbar"]/div/ul[3]/li[3]/a')
addBlock.click()
WebDriverWait(driver,5).until(expected_conditions.presence_of_element_located((By.ID,'allEntries')))
driver.find_element(By.ID,'allEntries').send_keys('客户管理')
WebDriverWait(driver,5).until(expected_conditions.presence_of_element_located((By.ID,'entryBlock')))
driver.find_element(By.ID,'entryBlock').send_keys('订单列表')
sleep(5)
driver.find_element(By.XPATH,'//*[@id="paramstype_chosen"]/a').click()
sleep(5)
driver.find_element(By.XPATH,'//*[@id="blockForm"]/table/tbody/tr[2]/td/div/div/div/button').click()
sleep(5)
# driver.find_element(By.XPATH,'//*[@id="blockForm"]/table/tbody/tr[2]/td/div/div/div/div/li[2]').click()
# sleep(5)
# driver.find_element(By.XPATH,'//*[@id="paramsorderBy_chosen"]/a').click()
# driver.find_element(By.XPATH,'//*[@id="paramstype_chosen"]/div/ul/li[2]').click()
# sleep(5)
# driver.find_element(By.ID,'params[num]').send_keys('20')
# sleep(5)
# driver.find_element(By.XPATH,'//*[@id="paramsorderBy_chosen"]/a/span').send_keys('产品')
# sleep(5)
# driver.find_element(By.XPATH,'//*[@id="paramsorderBy_chosen"]/div/ul/li[3]]').click()
# sleep(5)
driver.find_element(By.ID,'submit').click()
sleep(5)
# openBlock = driver.find_element(By.)
# driver.switch_to.frame('iframe-superadmin')
# addUser = driver.find_element(By.XPATH,'//*[@id="shortcutBox"]/div/div[1]/div/a')
# addUser.click()
# sleep(20)
# def send_id_keys(id,keys):
#     selected = driver.find_element(By.ID, id)
#     selected.send_keys(keys)
##########添加成员页面
# account = driver.find_element(By.ID,'account')
# account.send_keys('okk')
# realname = driver.find_element(By.ID,'realname')
# realname.send_keys('realokk')
# sexM = driver.find_element(By.ID,'genderm')
# genderf = driver.find_element(By.ID,'genderf')
# sexM.click()
#1.
# driver.find_element(By.ID,"role").send_keys("研发")
# #2.
# driver.find_element(By.ID,"role").click()
# sleep(2)
# driver.find_element(By.XPATH,'//*[@id="role"]/option[2]').click()
# #3.
# elements = driver.find_elements(By.TAG_NAME,"option")
# for element in elements:
#     if element.get_attribute("value")=="office":
#         element.click()
# sleep(3)
# #4.
# # roleSelect = Select(driver.find_element(By.ID,'role'))
# # roleSelect.select_by_value('dev')
# password1 = driver.find_element(By.ID,'password1')
# password1.send_keys('123456')
# sleep(2)
# password2 = driver.find_element(By.ID,'password2')
# password2.send_keys('123456')
# sleep(2)
# email = driver.find_element(By.ID,'email')
# email.send_keys('123@qq.com')
# submit = driver.find_element(By.ID,'submit')
# submit.click()
# sleep(10)
# driver.switch_to.parent_frame()
# icon1 = driver.find_element(By.XPATH,'//*[@id="s-menu-allapps"]/button')
# icon1.click()
# sleep(10)

